<%
class LoginAction

	sub do_login
		dim rs
		if isEmpty( that.form("admin") ) Then
			call that.error("您访问的页面不存在！！")
		End If
		
		if isEmpty( that.form("verify") ) or that.form("verify") <> S_("verify") Then
			call that.error("验证码错误！！")
		End If
		
		set rs = M_("user").db.where( "username = '" & that.form("admin") & "'" ).find()
		
		if POP_MVC.count(rs) < 1 Then
			set rs = nothing
			call that.error("用户<strong>" & that.form("username") & "</strong>不存在")
		End If
		
		if rs("password") <> md5(that.form("password")) Then
			set rs = nothing
			call that.error("密码错误")
		End if
		
		if rs("status") = 0 Then
			set rs = nothing
			call that.error("你被禁止登陆后台")
		End If
		Call S_( array("admin" , rs))
		call that.success( array("登陆成功", U_("Index/index") ) )
	End Sub
	
	sub verify
		call that.verify
	end sub
	
	sub Logout
		session.contents.remove("admin")
		call that.redirect( "Login/index" )
	End sub
	
	Sub options() 
		dim str
		str = "var _ADMIN_NAME = 'admin';"
		str = str & "var _USER = " & json_encode(S_("admin") ) & ";"
		str = str & "var APP_PATH = """ & POP_MVC.getConfig("TMPL_PARSE_STRING")("__APP__") & """;"
		Response.Write str
	End Sub
End Class
%>